package cn.mogugo.joke.tld;

import java.io.IOException;
import java.util.List;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTagSupport;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import cn.mogugo.comm.PageSupport;
import cn.mogugo.joke.manager.JokeObjManager;

public class JokeObjNewTld extends BodyTagSupport {
	/**
	 * 数量
	 */
	private Integer pageSize;
	
	public List listObjNew;
	
	
	public int doStartTag() throws JspTagException {
		WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(pageContext.getServletConfig().getServletContext());
		JokeObjManager jokeObjManager = (JokeObjManager) context.getBean("jokeObjManager");
		PageSupport page = jokeObjManager.getPage(null, 1, pageSize , "new");
		listObjNew = page.getItems();
		return this.EVAL_BODY_AGAIN;
	}
	
	
	public int doEndTag() throws JspException {

		BodyContent bc = getBodyContent();
		String body = bc.getString();
        try {
            pageContext.getOut().print(body);
        } catch (IOException e) {
        }
		
		return this.EVAL_PAGE;
				
		
	}
	
	
	


	public Integer getPageSize() {
		return pageSize;
	}
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
}
